import store from '@/store';
import { getCustomerApi } from '@/api/sj/customer-crm';
import to from 'await-to-js';

export const useCustomerStore = defineStore('customer',()=>{
    const customerList = ref<any[]>([]);

    /** 获取客户列表 */
    const getCustomerData = async () => {
        const [err,res] = await to(getCustomerApi({pageSize: 999, pageNum: 1}));
        if(res){
            customerList.value = res.rows;
            return Promise.resolve();
        }
        return Promise.reject(err);
        // const { code, rows } = await listCustomer({pageSize: 999, pageNum: 1});
        // if(code == 200){
        //     customerList.value = rows;
        // };
    };
    
    return {
        customerList,
        getCustomerData
    }
});

export default useCustomerStore;